package com.vegetable.modules.entity.bank.vo;

import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

@Data
public class PSBCTran {
    /**
     * 交易日期
     */
    @Excel(name ="序号", fixedIndex = 0)
    private Integer indexNo;
    /**
     * 交易日期
     */
    @Excel(name ="交易日期", fixedIndex = 1, format = "yyyy-MM-dd")
    private Date tranDate;
    /**
     * 交易时间
     */
    @Excel(name ="交易时间", fixedIndex = 2, format = "HH:mm:ss")
    private Date tranTime;

    @Excel(name = "记账日期", fixedIndex = 3 , format = "yyyy-MM-dd")
    private Date orderTime;

    @Excel(name ="支出金额", fixedIndex = 4)
    private String outAmountStr;

    @Excel(name ="收入金额", fixedIndex = 5)
    private String inAmountStr;

    @Excel(name ="余额", fixedIndex = 6)
    private String balanceAmountStr;

    public BigDecimal getOutAmount() {
        if (outAmountStr == null) return null;
        // 清理货币符号和千位分隔符（保留小数点和负号）
        String cleanValue = outAmountStr
                .replaceAll("[^\\d.-]", "")  // 移除非数字、非小数点、非负号
                .replaceAll("(?<=\\d)-(?=\\d)", ""); // 移除数字间的短横（如千位分隔符）

        // 处理空字符串
        if (cleanValue.isEmpty()) return null;
        return new BigDecimal(cleanValue);
    }

    public BigDecimal getInAmount() {
        if (inAmountStr == null) return null;
        // 清理货币符号和千位分隔符（保留小数点和负号）
        String cleanValue = inAmountStr
                .replaceAll("[^\\d.-]", "")  // 移除非数字、非小数点、非负号
                .replaceAll("(?<=\\d)-(?=\\d)", ""); // 移除数字间的短横（如千位分隔符）

        // 处理空字符串
        if (cleanValue.isEmpty()) return null;
        return new BigDecimal(cleanValue);
    }

    public BigDecimal getBalanceAmount() {
        if (balanceAmountStr == null) return null;
        // 清理货币符号和千位分隔符（保留小数点和负号）
        String cleanValue = balanceAmountStr
                .replaceAll("[^\\d.-]", "")  // 移除非数字、非小数点、非负号
                .replaceAll("(?<=\\d)-(?=\\d)", ""); // 移除数字间的短横（如千位分隔符）

        // 处理空字符串
        if (cleanValue.isEmpty()) return null;
        return new BigDecimal(cleanValue);
    }

    @ApiModelProperty(name ="支出金额")
    private BigDecimal outAmount;

    @ApiModelProperty(name ="收入金额")
    private BigDecimal inAmount;

    @ApiModelProperty(name ="余额")
    private BigDecimal balanceAmount;

    @Excel(name = "对方账号", fixedIndex = 7)
    private String bankNo;

    @Excel(name = "对方户名", fixedIndex = 8)
    private String counterparty;

    @Excel(name = "对方行名", fixedIndex = 9)
    private String bankName;

    @Excel(name = "用途", fixedIndex = 10)
    private String purpose;

    @Excel(name = "附言", fixedIndex = 11)
    private String postScript;

    @Excel(name = "摘要", fixedIndex = 12)
    private String summary;

    @Excel(name ="交易流水号", fixedIndex = 13)
    private String tradingNo;

    @Excel(name ="全局路由号", fixedIndex = 14)
    private String routerNo;
}
